home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / scpainter.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-12-18  |  4.8 KB  |  176 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7.  
  8. #ifndef __SCPAINTER_H__
  9. #define __SCPAINTER_H__
  10.  
  11. #include <QPainterPath>
  12. #include <QPainter>
  13. #include <QVector>
  14. #include <QStack>
  15. #include <QColor>
  16. #include <QMatrix>
  17. #include <QFont>
  18. #include <QImage>
  19. #include "scribusapi.h"
  20. #include "scconfig.h"
  21. #include "fpoint.h"
  22. #include "fpointarray.h"
  23. #include "vgradient.h"
  24. #include "scpattern.h"
  25.  
  26. #ifdef HAVE_CAIRO
  27. typedef struct _cairo cairo_t;
  28. typedef struct _cairo_surface cairo_surface_t;
  29. typedef struct _cairo_pattern cairo_pattern_t;
  30. #endif
  31.  
  32. class SCRIBUS_API ScPainter
  33. {
  34. public:
  35.     ScPainter( QImage *target, unsigned int w, unsigned int h, double transparency = 1.0, int blendmode = 0 );
  36. #ifdef HAVE_CAIRO
  37.     ScPainter( QString target, unsigned int w, unsigned int h, double transparency = 1.0, int blendmode = 0 );
  38. #endif
  39.     virtual ~ScPainter();
  40.     enum FillMode { None, Solid, Gradient, Pattern };
  41.     virtual void beginLayer(double transparency, int blendmode, FPointArray *clipArray = 0);
  42.     virtual void endLayer();
  43.     virtual void setAntialiasing(bool enable);
  44.     virtual void begin();
  45.     virtual void end();
  46.     void clear();
  47.     virtual void clear( const QColor & );
  48.  
  49.     // matrix manipulation
  50.     virtual void setWorldMatrix( const QMatrix & );
  51.     virtual const QMatrix worldMatrix();
  52.     virtual void setZoomFactor( double );
  53.     virtual double zoomFactor() { return m_zoomFactor; }
  54.     virtual void translate( double, double );
  55.     virtual void rotate( double );
  56.     virtual void scale( double, double );
  57.  
  58.     // drawing
  59.     virtual void moveTo( const double &, const double & );
  60.     virtual void lineTo( const double &, const double & );
  61.     virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
  62.     virtual void newPath();
  63.     virtual void closePath();
  64.     virtual void fillTextPath();
  65.     virtual void strokeTextPath();
  66.     virtual void fillPath();
  67.     virtual void strokePath();
  68.     virtual void setFillRule( bool fillRule );
  69.     virtual bool fillRule() { return m_fillRule; }
  70.     virtual void setFillMode( int fill );
  71.     virtual void setGradient( VGradient::VGradientType mode, FPoint orig, FPoint vec, FPoint foc = FPoint(0,0));
  72.     virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
  73.     virtual void setClipPath();
  74.  
  75.     virtual void drawImage( QImage *image );
  76.     virtual void setupPolygon(FPointArray *points, bool closed = true);
  77.     virtual void drawPolygon();
  78.     virtual void drawPolyLine();
  79.     virtual void drawLine(FPoint start, FPoint end);
  80.     virtual void drawRect(double, double, double, double);
  81.     virtual void drawText(QRectF area, QString text);
  82.  
  83.     // pen + brush
  84.     virtual QColor pen();
  85.     virtual QColor brush();
  86.     virtual void setPen( const QColor & );
  87.     virtual void setPen( const QColor &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
  88.     virtual void setPenOpacity( double op );
  89.     virtual void setLineWidth( double w);
  90.     virtual void setDash(const QVector<double>& array, double ofs);
  91.     virtual void setBrush( const QColor & );
  92.     virtual void setBrushOpacity( double op );
  93.     virtual void setOpacity( double op );
  94.     virtual void setFont( const QFont &f );
  95.     virtual QFont font();
  96.  
  97.     // stack management
  98.     virtual void save();
  99.     virtual void restore();
  100.  
  101.  
  102.     virtual void setRasterOp( int op );
  103.  
  104.     VGradient fill_gradient;
  105.     VGradient stroke_gradient;
  106.     ScPattern *m_pattern;
  107.  
  108. private:
  109.     void drawVPath( int mode );
  110. #ifdef HAVE_CAIRO
  111.     cairo_t *m_cr;
  112.     struct layerProp
  113.     {
  114.         cairo_surface_t *data;
  115.         int blendmode;
  116.         double tranparency;
  117.         FPointArray groupClip;
  118.         bool pushed;
  119.     };
  120. #else
  121.     QPainter painter;
  122.     QPainterPath m_path;
  123.     struct layerProp
  124.     {
  125.         QImage *data;
  126.         int blendmode;
  127.         double tranparency;
  128.         FPointArray groupClip;
  129.         bool pushed;
  130.     };
  131.     Qt::PenStyle PLineStyle;
  132. #endif
  133.     QStack<layerProp> Layers;
  134.     QImage *m_image;
  135.     double  m_layerTransparency;
  136.     int  m_blendMode;
  137.     unsigned int m_width;
  138.     unsigned int m_height;
  139.     QMatrix m_matrix;
  140.     QFont m_font;
  141.     bool mf_underline;
  142.     bool mf_strikeout;
  143.     bool mf_shadow;
  144.     bool mf_outlined;
  145.     /*! \brief Filling */
  146.     QColor m_fill;
  147.     double fill_trans;
  148.     bool m_fillRule;
  149.     int fillMode;                // 0 = none, 1 = solid, 2 = gradient 3 = pattern
  150.     int gradientMode;        // 1 = linear, 2 = radial
  151.     double patternScaleX;
  152.     double patternScaleY;
  153.     double patternOffsetX;
  154.     double patternOffsetY;
  155.     double patternRotation;
  156.     /*! \brief Stroking */
  157.     QColor m_stroke;
  158.     double stroke_trans;
  159.     double LineWidth;
  160.  
  161.     /*! \brief Line End Style */
  162.     Qt::PenCapStyle PLineEnd;
  163.   /*! \brief Line Join Style */
  164.     Qt::PenJoinStyle PLineJoin;
  165.   /*! \brief The Dash Array */
  166.     QVector<double> m_array;
  167.     double m_offset;
  168.     /*! \brief Zoom Factor of the Painter */
  169.     double m_zoomFactor;
  170.     bool imageMode;
  171.     bool layeredMode;
  172.     bool svgMode;
  173. };
  174.  
  175. #endif
  176.